home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 194 / pascal / xyplot.doc < prev    next >
Encoding:
Text File  |  1987-11-19  |  3.6 KB  |  68 lines

  1. XYPLOT.PAS  is  a  program  to  plot  any  arbitrary  curve  on  a 
  2. monochrome  monitor.   The program asks the user for a  lower  and 
  3. upper  bpund of X,  evaluates the function 540 times to  determine 
  4. the range of Y, and the evaluates the function 540 times again and 
  5. plots the function in a graphic window.  The program automatically 
  6. scales  so  that  the usefull part of the  screen  is  completely 
  7. filled,  except for a small margin at the top and bottom. Once the 
  8. curve  is  displayed you can evaluate the function for  any  point 
  9. included in the display. 
  10.  
  11. One  use would be to diminish the X bounds,  and run  the  program 
  12. again,  thus 'zooming in'.  You can very quickly find the roots of 
  13. an equation by a few runs of the program.
  14.  
  15. The program works with both continuous functions, where you supply 
  16. the  function,   or  with  arrays.    The  program   automatically 
  17. interpolates within an array based on the two samples adjacent  to 
  18. the value of X wanted by the plot routine.   In some applications, 
  19. a smoothing function might be inserted between the program and the 
  20. array.  Thus,  GofX  would be a smoothing function which  did  the 
  21. actual call to get array values.  
  22.  
  23. Since Files are simply conceptual extensions of arrays;  you could 
  24. either  read a text FILE into an array,  or read the file once  to 
  25. determine the range of Y and a second time to do the actual plot.
  26.  
  27. As  provided  here,  the plotter is embedded  in  a  demonstration 
  28. program so you can experiment with it a bit. Four sample functions 
  29. and one sample array are provided.   If you decide you can use it, 
  30. extract the procedure XYPLOT and import it into your own  program.  
  31. That program must be a GEM based program.  That is, it starts out: 
  32. IF Init_Gem THEN .....    .   Don't be put off by the size of  the 
  33. program,  most of the size originates in the demonstration, not in 
  34. the plot procedure per se.   A lot of the size is caused by dialog 
  35. boxes you will never see unless you make faulty entries of various 
  36. kinds.
  37.  
  38. The  approach seems kind of 'backwards' because the main  program, 
  39. the GofX you provide,  is buried in a function.  But nowhere is it 
  40. written that a function has to be 'smallish'.  So GofX might  well 
  41. be several thousand bytes long.
  42.  
  43. The  program includes a string to number convertor that  might  be 
  44. usefull in its own right, too.  The rules followed are liberalized 
  45. rules so it will accept any valid integer,  long_integer or  real. 
  46. The liberalization relaxes the Pascal rules for decimal points  in 
  47. real  numbers.   There  is  extensive  use  of  recursion  in  the 
  48. convertor  which  might be of some value as a  tutorial.  You  can 
  49. specify the numeric result as being either integer,  long_integer, 
  50. or real.
  51.  
  52. I  would  consider requests to enhance the program.   I  think  it 
  53. demonstrates  nicely  the potential for the ST  in  doing  serious 
  54. work.   The  notion of a built in XY plotter was a strong part  of 
  55. the  attraction of the ST when I bought mine.   This has a lot  of 
  56. appeal when you have, as I have,  spent written many programs that 
  57. write  crude  'X's on printers trying to convey the  notion  of  a 
  58. smooth curve!  
  59.  
  60. Since I don't have a color monitor,  I didn't provide for it.   It 
  61. shouldn't  be  too hard to modify the program  to  accomodate  it.  
  62. Just do a search for the numbers 640 and 540 and that should  lead 
  63. you to all of the monochrome unique code.  (540 because 100 pixels 
  64. are reserved for the text on the left side of the display.)
  65.  
  66.                               Merlin Hanson
  67.                               Genie: M.L.HANSON
  68.